/*
 *  $Id: ParticleGenerator.cs 1042 2010-05-15 20:52:33Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System.Collections.Generic;

using AgateLib.Geometry;

namespace Ragima.UI {
    /// <summary>
    /// Стандартные генераторы частиц.
    /// </summary>
    public static class ParticleGenerator {
        /// <summary>
        /// Генератор одинаковых частиц по генератору координат.
        /// </summary>
        /// <param name="info">Информация о частице</param>
        /// <param name="points">Генератор координат</param>
        public static IEnumerable<Particle> Same(ParticleInfo info, IEnumerable<Point> points) {
            foreach (Point point in points)
                yield return new Particle(info, point);
        }

        public static IEnumerable<Particle> RandomAngle(ParticleInfo info, IEnumerable<Point> points, params double[] angleOffsets) {
            foreach (Point point in points) {
                double angle = 360 * Randomizer.Global.NextDouble();
                info.Phases[0].Angle = angle;
                int j = 0;
                double offset = 0;
                for (int i = 1; i < info.Phases.Count; i++) {
                    if (j < angleOffsets.Length) {
                        offset = angleOffsets[j];
                        j++;
                    }
                    info.Phases[i].Angle = angle + offset;
                }
                yield return new Particle(info, point);
            }
        }
    }
}
